// 导航守卫
import store from '@/store/index'
import route from '@/router/index.js'
// 白名单
const pageArr = ['/404', '/login']
// 前置守卫
route.beforeEach((to, from, next) => {
  if (store.getters.token) {
    if (to.path.toLowerCase() === '/login') {
      next('/')
    } else {
      next()
    }
  } else {
    if (pageArr.includes(to.path.toLowerCase())) {
      next()
    } else {
      next('/login')
    }
  }
})
// 后置守卫
route.afterEach((to, next) => {})
